﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace visu.Controllers
{
    public class HomeController : Controller
    {

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Menu()
        {
            ViewData.Model = OperateContext.SessMenuPermission;
            return View();
        }

        public ActionResult Login()
        {
            string username = Request.Cookies["username"] == null ? null : Request.Cookies["username"].Value;
            string company = Request.Cookies["company"] == null ? null : Request.Cookies["company"].Value;
            string password = Request.Cookies["password"] == null ? null : Request.Cookies["password"].Value;

            ViewData["IsCookie"] = !string.IsNullOrEmpty(username);
            ViewData["username"] = HttpUtility.UrlDecode(username, Encoding.GetEncoding("UTF-8"));
            ViewData["company"] = HttpUtility.UrlDecode(company, Encoding.GetEncoding("UTF-8"));
            ViewData["password"] = password;
            return View();
        }

        public ActionResult LoginMethod(string username, string password, string comp, string auto)
        {
            return Json(BLLSession.Current.userBLL.LoginMethod(username, password, comp, auto), JsonRequestBehavior.AllowGet);
        }

        public ActionResult Bottom()
        {
            return View();
        }
    }
}
